﻿using System.Resources;

namespace SilverlightApplication.LanguageResources
{
    public enum Languages
    {
        English,
        Spanish
    }
    public static class LanguageLoader
    {
        private static ResourceManager resManager;

        public static void SetLanguage(Languages language)
        {
            switch (language)
            {
                case Languages.English: resManager = English.ResourceManager;
                    break;
                case Languages.Spanish: resManager = Spanish.ResourceManager;
                    break;
            }
        }

        public static string GetString(string key)
        {
            string ret = string.Empty;
            if(resManager == null)
                return "Unable to load Resource";

            try
            {
                ret = resManager.GetString(key);
            }
            catch
            {
                ret = "Unable to find " + key +" key";
            }

            return ret;
        }
    }
}
